package com.shine.reflect;

import javax.swing.text.DefaultEditorKit;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @program: reflect
 * @description:
 * @author: Shine
 * @create: 2019-07-24 09:11
 */
public class test {


    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        List list = new ArrayList<>();
        bee b1 = new bee();
        b1.setLegs(4);
        b1.setWight(1234D);
        b1.setWings("color1");
        bee b2 = new bee();
        b2.setLegs(3);
        b2.setWight(1234D);
        b2.setWings("color2");
        bee b3 = new bee();
        b3.setLegs(2);
        b3.setWight(1234D);
        b3.setWings("color3");
        bee b4 = new bee();
        b4.setLegs(1);
        b4.setWight(1234D);
        b4.setWings("color4");
        tree tree = new tree();
        tree.setColor("black");
        tree.setHigh(111D);
        list.add(b1);
        list.add(b2);
        list.add(b3);
        list.add(b4);
        list.add(tree);

        List<Map<String, Object>> listProperty = new ReflectUtils<Object>().getListProperty(list);
        for (Map<String, Object> stringObjectMap : listProperty) {
            Set<Map.Entry<String, Object>> entries = stringObjectMap.entrySet();
            for (Map.Entry<String, Object> entry : entries) {
                String key = entry.getKey();
                Object value = entry.getValue();
                System.out.println(key+"-----"+value);
            }
        }
    }
}
